<script setup lang="ts">
import { ref, reactive } from 'vue'
//父子通信demo
import Demo from '../home/demo.vue'
const state = reactive({
  data: '奔驰',
})
// 子传父
const handleData = (flag: string, val: any) => {
  console.log(flag, val)
  state.data = val
}
const handleDataChange = () => {
  state.data = '奔驰'
}
</script>

<template>
  <div>
    <h2>父子通信</h2>
    <div>
      <button @click="handleDataChange">父事件</button>
      <Demo :data="state.data" @handleData="handleData" />
    </div>
  </div>
</template>

<style scoped lang="scss">
@import './index.scss';
</style>
 